#ifndef __GAMEMAP_H__
#define __GAMEMAP_H__

#include "FindPath.h"
#include "a_star_path_finder.h"

enum DefaultValue
{
	MAP_FILE_FLAG	= MAKELONG(MAKEWORD('A','S'),MAKEWORD('M','P')),
};

class CGameMap
{
public:
	CGameMap()
		: is_empty_(true), data_(NULL)
	{};
	virtual ~CGameMap(void);
	void LoadMap(CArchive& ar);
	void SaveMap(CArchive& ar);
	void DrawMap(CDC* pDC);
	PathFinder::FindResult FindPath();
	inline bool is_empty () { return is_empty_; }
	inline int get_width() { return width_ * 4; }
	inline int get_height() { return height_ * 4; }
	inline void set_start(CPoint pt) { start_ = pt; }
	inline void set_end(CPoint pt) { end_ = pt; }
private:
	inline bool is_moveable(int x, int y) { return 0 == data_[y * width_ + x]; }
	inline int get_move_cast(int x, int y) { return 1; }
private:
	bool is_empty_;
	long flag_;
	int width_;
	int height_;
	unsigned char* data_;
	CPoint start_;
	CPoint end_;

	PathFinder finder_;
	std::vector<PathFinder::Point> path_;
};

#endif//__GAMEMAP_H__